﻿using System.Collections.Generic;
using System.Xml;

namespace BuzzX8.Xmpp.StreamElements
{
    public class StreamFeaturesList : CompositeElement<StreamFeature>
    {
        public StreamFeaturesList() : base("features", "stream", XmppNamespaces.Streams)
        {
        }

        public ICollection<StreamFeature> Features
        {
            get { return Elements; }
        }

        public bool HasFeatures
        {
            get { return Elements.Count > 0; }
        }

        public void AddFeature(StreamFeature feature)
        {
            Elements.Add(feature);
        }

        public void AddFeature(string featureName, string featureNamespace)
        {
            Elements.Add(new StreamFeature(featureName, featureNamespace));
        }

        protected override void WriteElements(XmlWriter writer)
        {
            foreach (StreamFeature feature in Elements) feature.Write(writer);
        }
    }
}
